package com.bwei.topnews.manager;

import android.support.v4.app.Fragment;

import com.bwei.topnews.fragment.LocalCityFragment;
import com.bwei.topnews.fragment.MyFragment;

import java.util.LinkedHashMap;

/**
 * Created by qwe on 2016/11/16.
 */
public class FragmentFactory {
    private static LinkedHashMap<String,Fragment> fragmentLinkedHashMap = new LinkedHashMap<>();
    public static Fragment getFragment(String category){
        Fragment fragment = fragmentLinkedHashMap.get(category);
        if(fragment!=null){
            return fragment;
        }
        if(category.equals("news_local")){
            fragment = new LocalCityFragment();
        }else{
            fragment = MyFragment.getFragment(category);
        }
        fragmentLinkedHashMap.put(category,fragment);
        return fragment;
    }
}
